<?php

  /**
   * classe Liste_Paginee dérive la classe Liste et implémente
   * l'adapteur du Paginator de Zend
   */


class Liste_Paginee implements Zend_Paginator_Adapter_Interface {

  protected $classeEnreg;
  protected $method;
  protected $clause;
  protected $data;

  public function __construct($classeEnreg, $method, $clause="1=1", $data=array()) {
    $this->classeEnreg = $classeEnreg;
    $this->method = $method;
    $this->clause = $clause;
    $this->data = $data;
  }

  public function count() {
    return call_user_func(array($this->classeEnreg, 'count'), $this->clause, $this->data);
  }

  public function getItems($offset, $itemsPerPage) {
    $this->data['offset'] = $offset;
    $this->data['itemsPerPage'] = $itemsPerPage;

    return call_user_func(array($this->classeEnreg, $this->method), $this->clause, $this->data);
  }

}
?>